﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HCQ2_IBLL;
using HCQ2_Model.DocModel.APIResultModel;
using HCQ2_Model.DocModel;
using HCQ2_Model.SelectModel;
using HCQ2_Model.WeiXinApiModel.ResultApiModel;

namespace HCQ2_BLL
{
    public partial class T_VRCustomPassBLL: IT_VRCustomPassBLL
    {
        /// <summary>
        ///  获取关卡列表
        /// </summary>
        /// <param name="model">参数</param>
        /// <param name="total">数量</param>
        /// <returns></returns>
        public List<HeadPassModel> GetTableData(HeadTableParamModel model, out int total)
        {
            return DBSession.IT_VRCustomPassDAL.GetTableData(model,out total);
        }
        /// <summary>
        ///  获取课件集合
        /// </summary>
        /// <param name="folder_id"></param>
        /// <param name="isOk">是否为已上架</param>
        /// <param name="notStatus">是否排除审核不通过的</param>
        /// <returns></returns>
        public List<SelectModel> GetClassData(int folder_id, bool isOk, bool notStatus = false)
        {
            return DBSession.IT_VRCustomPassDAL.GetClassData(folder_id, isOk);
        }
        /// <summary>
        ///  获取用户课件列表
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="fileId">课件id</param>
        /// <returns></returns>
        public List<VRCustomPassRecord> GetCustomList(int userId, int fileId)
        {
            List<VRCustomPassRecord> list = DBSession.IT_VRCustomPassDAL.GetCustomList(userId, fileId);
            for (int i=0;i<list.Count;i++)
            {
                if (list[i].score >= 60)
                {
                    list[i].status = 1;
                    list[i].star = GetStarNum(list[i].score);
                }
                else if (list[i].score < 60)
                {
                    list[i].star = 0;
                    //第一关
                    if (list[i].rowNumber == 1)
                        list[i].status = 0;
                    //其他关卡
                    else if (list[i - 1].score >= 60)
                        list[i].status = 0;
                    else
                        list[i].status = -1;
                }
            }
            return list;
        }
        private int GetStarNum(decimal score)
        {
            if (score < 60)
                return 0;
            else if (score >= 60 && score < 70)
                return 1;
            else if (score >= 70 && score < 80)
                return 2;
            else if (score >= 80 && score < 90)
                return 3;
            else if (score >= 90 && score < 100)
                return 4;
            else
                return 5;
        }
    }
}
